import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '工厂编码',
    align: 'center',
    dataIndex: 'factoryCode',
  },
  {
    title: '工厂名称',
    align: 'center',
    dataIndex: 'factoryName',
  },
  {
    title: '位置',
    align: 'center',
    dataIndex: 'factoryLocation',
  },
  {
    title: ' 联系人',
    align: 'center',
    dataIndex: 'factoryAdmin',
  },
  {
    title: '联系方式',
    align: 'center',
    dataIndex: 'factoryConcat',
  },
  {
    title: '介绍',
    align: 'center',
    dataIndex: 'factoryDescription',
  },
  {
    title: '备注',
    align: 'center',
    dataIndex: 'remark',
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '工厂编码',
    field: 'factoryCode',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: '工厂名称',
    field: 'factoryName',
    component: 'Input',
    colProps: { span: 6 },
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '工厂编码',
    field: 'factoryCode',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入工厂编码!' }, { ...rules.duplicateCheckRule('camellia_factory', 'factory_code', model, schema)[0] }];
    },
  },
  {
    label: '工厂名称',
    field: 'factoryName',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入工厂名称!' }];
    },
  },
  {
    label: '位置',
    field: 'factoryLocation',
    component: 'Input',
  },
  {
    label: ' 联系人',
    field: 'factoryAdmin',
    component: 'Input',
  },
  {
    label: '联系方式',
    field: 'factoryConcat',
    component: 'Input',
  },
  {
    label: '介绍',
    field: 'factoryDescription',
    component: 'InputTextArea',
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
